import request from '@/utils/request'

const api_name = '/admin/acl/permission'

export default {
  getPermissionById(id) {
    return request({
      url: `${api_name}/get/${id}`,
      method: 'get',
    })
  },
  getPermissionList() {
    return request({
      url: `${api_name}/permissionList`,
      method: 'get',
    })
  },

  getNestedTreeList() {
    return request({
      url: `${api_name}`,
      method: 'get',
    })
  },
  removeById(id) {
    return request({
      url: `${api_name}/remove/${id}`,
      method: 'delete',
    })
  },
  saveLevelOne(menu) {
    return request({
      url: `${api_name}/save`,
      method: 'post',
      data: menu,
    })
  },
  update(menu) {
    return request({
      url: `${api_name}/update`,
      method: 'put',
      data: menu,
    })
  },
  doAssign(roleId, permissionId) {
    return request({
      url: `${api_name}/doAssign`,
      method: 'post',
      data: { roleId:roleId, permissionId:permissionId },
    })
  },
  listMenuOptions(){
    return request({
      url: `${api_name}/options`,
      method: 'get',
    })
  }
}
